//
//  AcgCell.m
//  oc1
//
//  Created by kokuma on 2017/2/11.
//  Copyright © 2017年 kokumams. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AcgCell.h"
#import "UIColor+expanded.h"
#import "UIImageView+WebCache.h"
#import "VenueBean.h"

@interface AcgCell ()
@property (strong, nonatomic) UIImageView *userIconView;
@property (strong, nonatomic) UILabel *name;

@end

@implementation AcgCell


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUpContentView];
        
    }
    return self;
}

- (id)setUpContentView
{
    if (self) {
        
        // Initialization code
       // CGFloat screen = [UIScreen mainScreen].bounds.size.width;
       //  NSLog(@(screen));
         self.contentView.backgroundColor = [UIColor whiteColor];
        if (!_userIconView) {
           // _userIconView = [[UIImageView alloc] initWithFrame:CGRectMake(5,5, screen/2-35, [AcgCell cellHeight]-60)];
             _userIconView = [UIImageView alloc];
            [_userIconView initWithFrame:CGRectMake(5,5, self.frame.size.width-10, self.frame.size.height-50)];
            [self.contentView addSubview:_userIconView];
            // [_userIconView doCircleFrame];
            _userIconView.backgroundColor = [UIColor greenColor];
            
        }
        if (!_name) {
            _name = [UILabel alloc];
            //_name.frame = CGRectMake(_name.frame.origin.x,_name.frame.origin.y, 150, 25);
           // [_name initWithFrame:CGRectMake(5,[AcgCell cellHeight]-30, screen/2-45, 30)];
            [_name initWithFrame:CGRectMake(5,self.frame.size.height-40, self.frame.size.width-10, 30)];
            [self.contentView addSubview:_name];
            _name.textAlignment = NSTextAlignmentCenter;
            _name.font = [UIFont systemFontOfSize:12];
            _name.textColor = [UIColor blackColor];
             _name.backgroundColor = [UIColor whiteColor];
        }
    
    }
    return self;
}

- (void)configViewWithModel:(AcgBean *)model{
    _bean = model;
    NSString *str = @"http://mbpcos.image.alimmdn.com/avatar/D6B77C75-42B1-4AB6-9A99-2FD06381CC11@50w";
    if (_bean) {
        str = _bean.frontCover;
    }
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    //[_userIconView sd_setImageWithURL:url];
    [_userIconView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"a"]];
    
    _name.text = @"kokuma";
    if(_bean&&_bean.name){
        _name.text = _bean.name;
    }

}




+ (CGFloat)cellHeight{
    return 150.0;
}

@end